﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Nova_MOD;

namespace Nova_BLL
{
    public class LCDTaskbll
    {
        DataSet ds = null;
        Nova_DAL.LCDTask DalLCDTask = new Nova_DAL.LCDTask();


        /// <summary>
        /// 获取LCDTask 的数据列表
        /// </summary>
        /// <returns>异常情况和没有获取到数据，返回空的列表</returns>
        public List<LCDTask> GetALLLCDTaskInfor()
        {
            List<LCDTask> listLCDTask = new List<LCDTask>();
            try
            {
                ds = DalLCDTask.QueryALLLCDTaskInfor();
                if (ds != null && ds.Tables[0].Rows.Count > 0)
                {
                   
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        Nova_MOD.LCDTask LCDTask = new Nova_MOD.LCDTask();
                        LCDTask.SQID =int.Parse(ds.Tables[0].Rows[i]["SQID"].ToString());
                        LCDTask.TaskID =long.Parse(ds.Tables[0].Rows[i]["TaskID"].ToString());
                        LCDTask.TaskMode = ds.Tables[0].Rows[i]["TaskMode"].ToString();
                        LCDTask.Tray_ID = ds.Tables[0].Rows[i]["Tray_ID"].ToString();
                        LCDTask.Mat_Code = ds.Tables[0].Rows[i]["Mat_Code"].ToString();
                        LCDTask.Mat_Name = ds.Tables[0].Rows[i]["Mat_Name"].ToString();
                        LCDTask.Mat_Num = int.Parse(ds.Tables[0].Rows[i]["Mat_Num"].ToString());
                        LCDTask.UpdateTime =Convert.ToDateTime(ds.Tables[0].Rows[i]["UpdateTime"].ToString());
                        listLCDTask.Add(LCDTask);
                    }

                }
            }
            catch
            {
                return new List<LCDTask>();
            }
            
            

            return listLCDTask;
        }


        /// <summary>
        /// 获取多少分钟内TLCDLog拼接信息 字符串
        /// </summary>
        /// <param name="minute"></param>
        /// <returns>异常：返回错误提示 ； 没有数据，返回“”</returns>
        public string GetShowLCDLogInfor(int minute)
        {
            string ShowLCDLogInfor = "";
            try
            {
                ds = DalLCDTask.QueryLCDLogInfor(minute);
                if (ds != null && ds.Tables[0].Rows.Count > 0)
                {

                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        ShowLCDLogInfor += ds.Tables[0].Rows[i]["SQID"].ToString();
                        ShowLCDLogInfor += ":";
                        ShowLCDLogInfor += ds.Tables[0].Rows[i]["Infor"].ToString();
                        ShowLCDLogInfor += "&";
                        ShowLCDLogInfor += ds.Tables[0].Rows[i]["UpdateTime"].ToString();
                        ShowLCDLogInfor += ";<br>";
                        
                    }

                }
            }
            catch
            {
                ShowLCDLogInfor = "获取LCD显示信息异常";
                return ShowLCDLogInfor;
            }

            return ShowLCDLogInfor;
        }

    }
}
